Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vue/composition-api

Package Overview
Dependencies
Maintainers
16
Versions
106
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vue/composition-api

Provide logic composition capabilities for Vue.

  • 0.6.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
142K
increased by8.63%
Maintainers
16
Weekly downloads
 
Created

What is @vue/composition-api?

@vue/composition-api is a plugin that provides Vue 2.x users with the Composition API, which is a set of APIs that allows you to use Vue 3's reactivity system and component logic composition in Vue 2.x applications.

What are @vue/composition-api's main functionalities?

Reactive State

The `reactive` function is used to create a reactive state object. This allows you to manage state in a reactive manner, similar to Vue 3.

```javascript
import { reactive } from '@vue/composition-api';

export default {
  setup() {
    const state = reactive({ count: 0 });
    return { state };
  }
};
```

Computed Properties

The `computed` function is used to create computed properties that automatically update when their dependencies change.

```javascript
import { computed } from '@vue/composition-api';

export default {
  setup() {
    const state = reactive({ count: 0 });
    const doubleCount = computed(() => state.count * 2);
    return { state, doubleCount };
  }
};
```

Watchers

The `watch` function is used to perform side effects in response to reactive state changes.

```javascript
import { watch } from '@vue/composition-api';

export default {
  setup() {
    const state = reactive({ count: 0 });
    watch(() => state.count, (newValue, oldValue) => {
      console.log(`Count changed from ${oldValue} to ${newValue}`);
    });
    return { state };
  }
};
```

Lifecycle Hooks

The `onMounted` and `onUnmounted` functions are used to register lifecycle hooks within the setup function.

```javascript
import { onMounted, onUnmounted } from '@vue/composition-api';

export default {
  setup() {
    onMounted(() => {
      console.log('Component is mounted');
    });
    onUnmounted(() => {
      console.log('Component is unmounted');
    });
  }
};
```

Other packages similar to @vue/composition-api

Keywords

FAQs

Package last updated on 24 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc